package com.bsj.pay.controller.partner;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bsj.pay.model.BalanceBean;
import com.bsj.pay.model.ChargeAccountBean;
import com.bsj.pay.model.PartnerBean;
import com.bsj.pay.service.BalanceService;
import com.bsj.pay.service.ChargeAccountService;
import com.bsj.pay.util.ResultUtil;
import com.github.pagehelper.PageInfo;

@RequestMapping("/partner/balance")
@Controller("partnerBalanceController")
public class BalanceController {
	@Autowired
	private BalanceService balanceService;
	
	@Autowired
	private ChargeAccountService chargeAccountService;
	
	@ResponseBody
	@RequestMapping(value = "/list.html")
	public Map list(HttpServletRequest req, HttpServletResponse res,int page,int limit,BalanceBean balance) {
		BalanceBean queryModel=new BalanceBean();
		PartnerBean puser=(PartnerBean) req.getSession().getAttribute("puser");
		queryModel.setUser_id(puser.getId());
		if(!StringUtils.isEmpty(balance.getRemarks()))queryModel.setRemarks(balance.getRemarks());
		if(!StringUtils.isEmpty(balance.getTimeStr()))queryModel.setTimeStr(balance.getTimeStr());
		PageInfo<BalanceBean> pageInfo=balanceService.pageList(queryModel, page, limit);
		return ResultUtil.getQuerySuccessResult(pageInfo);
	}
	
	@RequestMapping("/listPage.html")
    public ModelAndView listPage(HttpServletRequest request,HttpServletResponse response,ModelAndView mav) {
		mav.setViewName("partner/balance/list");
		return mav;
    }
	
	@ResponseBody
	@RequestMapping(value = "/dayFinanceList.html")
	public Map dayFinanceList(HttpServletRequest req, HttpServletResponse res,int page,int limit) {
		PartnerBean puser=(PartnerBean) req.getSession().getAttribute("puser");
		ChargeAccountBean queryModel=new ChargeAccountBean();
		queryModel.setPartner_id(puser.getId());
		PageInfo<ChargeAccountBean> pageInfo=chargeAccountService.pageDayFinanceList(queryModel, page, limit);
		return ResultUtil.getQuerySuccessResult(pageInfo);
	}
	
	@RequestMapping("/dayFinanceListPage.html")
    public ModelAndView dayFinanceListPage(HttpServletRequest request,HttpServletResponse response,ModelAndView mav) {
		mav.setViewName("partner/balance/dayFinanceList");
		return mav;
    }
}
